Skip to content

Conversation

@vvsotnikov
Copy link

Description

Problem

Hey, I tried installing x402 for a FastAPI project and noticed it installs all frameworks and clients (Flask, FastAPI, httpx, requests) as hard dependencies, even if you only need FastAPI.

This causes unnecessary bloat, potential version conflicts, and makes it harder to add new integrations in the future as more middleware and clients are added.

Solution

I propose moving framework and client deps to optional extras, with graceful import errors when missing.

This avoids import-time coupling and keeps the package lean and extensible for future integrations.

pip install x402[fastapi,httpx]   # only what you need
pip install x402[all]             # everything

Extras: flask, fastapi, httpx, requests, servers, clients, all

Added clear errors when deps are missing:

ImportError: httpx client requires the httpx package. Install with: pip install x402[httpx]

Breaking Changes

Frameworks and clients are no longer installed by default:

pip install x402[fastapi,httpx]  # or pip install x402 fastapi httpx

Clients are now imported from their submodules:

# before: from x402.clients import x402HttpxClient
# after:
from x402.clients.httpx import x402HttpxClient

I was considering using lazy imports instead, but it would've increased maintenance costs and probably is bad r/r.

Tests

No new tests needed. All existing tests are passing.

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits

@cb-heimdall
Copy link

cb-heimdall commented Dec 30, 2025

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@vercel
Copy link

vercel bot commented Dec 30, 2025

@vvsotnikov is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@phdargen
Copy link
Contributor

phdargen commented Jan 2, 2026

Thanks a lot for your suggestion @vvsotnikov! Agreed that it would be great if one could only install what is really needed, similar to what we are doing for the typescript packages.

With the v2 releases for the typescript and go implementations, we wont introduce any breaking changes to any of the legacy packages anymore. While python v2 is not live yet, we have a development branch up, see here #841.

I think it would be great to implement something like this for the python v2 release and would appreciate if you could write a comment on this PR #841 with you proposal. We could then gather some feedback from @CarsonRoscoe and others before implementing the changes.

New PRs for the python sdk should target the feat/python-v2-sdk branch for now

@phdargen phdargen closed this Jan 2, 2026
@vvsotnikov
Copy link
Author

Got it, thanks @phdargen !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants